home *** CD-ROM | disk | FTP | other *** search
- /*
- File ResXXXXEd.c
-
- Copyright Apple Computer, Inc. 1985-1988
- All rights reserved.
- */
-
- #include <types.h>
- #include <memory.h>
- #include <menus.h>
- #include <resources.h>
-
- #include "ResEd.h"
-
- typedef struct rXXXXRec {
- ParentHandle father; /* Back ptr to dad */
- str64 name; /* the name of this editor */
- WindowPtr windPtr; /* This view's window */
- Boolean rebuild; /* Set TRUE if things have changed */
- Handle hXXXX; /* The resource we are working on */
- MenuHandle menuXXXX; /* our menu */
- } rXXXXRec;
-
- typedef rXXXXRec *rXXXXPtr;
- typedef rXXXXPtr *rXXXXHandle;
-
- pascal void Debugger(/*void*/) extern 0xA9FF;
-
- /*- - - - - - - - - - - - - - - - - - - - - - - -*/
-
- pascal void EditBirth(Handle Thing, ParentHandle Dad)
- {
- rXXXXHandle MyXXXX;
- WindowPtr w;
- char s[256];
-
- /* Prepare window title and request creation of a new window */
- strcpy(s, "\pWindow");
- SetETitle((Handle)Thing, s);
- ConcatStr(s, "\p from ");
-
- /*If we got a new window, then start up the editor*/
- if (w = WindSetup(300, 100, s, (*Dad)->name)) {
- FixHand(sizeof(WindowRecord), (Handle)Thing); /* Make sure we have
- enough room in */
- /* the handle for a complete window */
- /* record. (later this will be */
- /* assigned to (*MyXXXX)->hXXXX */
-
- /* Get memory for and handle to our instance record */
- MyXXXX = (rXXXXHandle)NewHandle(sizeof(rXXXXRec)); /* Need to do size
- check? */
- HLock((Handle)MyXXXX);
- /* Put information about this incarnation of the editor and the window it is */
- /* serving into our record.(always passed around in the handle MyXXXX. */
-
- (*MyXXXX)->windPtr = w;
- (*MyXXXX)->father = Dad;
- (*MyXXXX)->hXXXX = Thing;
-
- /* Let the main program know who is to manage this window by giving it both */
- /* our resource ID number and our instance record handle */
- ((WindowPeek)w)->windowKind = ResEdID();
- ((WindowPeek)w)->refCon = (long)MyXXXX;
-
- /* Set up menus,the view, etc. for this window */
- HUnlock((Handle)MyXXXX);
- }
- }
-
- /*- - - - - - - - - - - - - - - - - - - - - - - -*/
-
- pascal void PickBirth(ResType t,ParentHandle Dad)
- {
- }
- /*- - - - - - - - - - - - - - - - - - - - - - - -*/
-
- pascal void DoEvent(EventRecord *Evt, rXXXXHandle MyXXXX)
- {
- Point MousePoint;
-
- BubbleUp((Handle)MyXXXX); /* Move our item up im memory */
- HLock((Handle)MyXXXX); /* Lock it down */
- /* Handle event passed to us by main program */
- /* Just like a 'real' event loop, exceptâ•” */
- /* there is no loop and we don't have to */
- /* handle as much because the main program */
- /* will do all the stuff that doesn't apply */
- /* to us. */
- MousePoint = Evt->where; /* Point at which the event occured */
- SetPort((*MyXXXX)->windPtr);/* Set the port to our window */
- GlobalToLocal(&MousePoint); /* Convert event location to local coords */
- switch (Evt->what) {
- case mouseDown:
- break;
-
- case activateEvt:
- AbleMenu(FileMenu, fileTop);
- if (Evt->modifiers & activeFlag) {
- /* Activate event */
- } else {
- /* Deactivate event */
- }
- break;
-
- case updateEvt:
- PaintRect(&(*MyXXXX)->windPtr->portRect);
- break;
-
- case keyDown:
- break;
-
- }
- HUnlock((Handle)MyXXXX);
- }
- /*- - - - - - - - - - - - - - - - - - - - - - - -*/
-
- pascal void DoInfoUpdate(short oldID, short newID, rXXXXHandle MyXXXX)
- {
- char s[256];
-
- /* Since our ID has changed, we need to change our window title */
- strcpy(s, "\pWindow");
- SetETitle((Handle)(*MyXXXX)->hXXXX, s);
- ConcatStr(s, "\p from ");
- ConcatStr(s, (*((*MyXXXX)->father))->name);
- SetWTitle((*MyXXXX)->windPtr, s);
-
- /* Now, let our father object know that our ID has been changed */
- CallInfoUpdate(oldID, newID, (*((*MyXXXX)->father))->wind->refCon,
- (*((*MyXXXX)->father))->wind->windowKind);
- }
- /*- - - - - - - - - - - - - - - - - - - - - - - -*/
-
- static void DoClose(rXXXXHandle MyXXXX)
- {
- CloseWindow((*MyXXXX)->windPtr); /* Close the window */
- WindFree((*MyXXXX)->windPtr); /* Mark the window record as being available */
- InitCursor(); /* Make sure the cursor is the arrow cursor */
- /* Delete any menus that we added and redraw menu bar */
- /* Be sure to dispose of any handles you are done with */
- DisposHandle((Handle)MyXXXX);
- }
-
- pascal void DoMenu(short Menu, short Item, rXXXXHandle MyXXXX)
- {
- short saveRefNum;
-
- BubbleUp((Handle)MyXXXX);
- HLock((Handle)MyXXXX);
- SetPort((*MyXXXX)->windPtr); /* Set the port to our window */
-
- /* Again, we handle the menu stuff just as we would in a 'real' application */
- /* except that we only have to handle those items that apply to ourselves. */
- switch (Menu) {
- case FileMenu:
- switch (Item) {
- case CloseItem:
- DoClose(MyXXXX); /* Close our window */
- return; /* Return to main program */
- break;
-
- case RevertItem:
- /* The area under window will need to be updated */
- InvalRect(&(*MyXXXX)->windPtr->portRect);
-
- /* We will need to restore the cur resource file */
- /* reference number when we are done here. */
- saveRefNum = CurrentRes();
-
- /* We are going to be using the resource file we */
- /* came from. */
- UseResFile(HomeResFile((Handle)(*MyXXXX)->hXXXX));
-
- /* Read in the old copy from disk (see documentation*/
- /* for revertResource). Clear it out unless this */
- /* was a newly created resource, in which case */
- /* don't. */
- if (!RevertResource((Handle)(*MyXXXX)->hXXXX)) {
- RmveResource((Handle)(*MyXXXX)->hXXXX);
- (*((*MyXXXX)->father))->rebuild = true;
- DoClose;
- return;
- }
- /* Go back to using old resource file. */
- UseResFile(saveRefNum);
- break;
-
- case GetInfoItem:
- ShowInfo((Handle)(*MyXXXX)->hXXXX, (ParentHandle)MyXXXX);
- break;
- }
-
- case EditMenu:
- switch (Item) {
- case CutItem: break;
- case CopyItem: break;
- case PasteItem: break;
- case ClearItem: break;
- }
- }
- }